﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DAO.WaiGaoQiao
{
    public class DataAccessUser
    {
        //public List<UserInfo> DA_GetUser()
        //{
        //    using (SqlConnection conn = new SqlConnection("server=localhost;database=TestDb;uid=sa;pwd=11"))
        //    {
        //        conn.Open();
        //        string insql = "select UserLogName,UserName,isnull(QuanXian,'') FROM Tbt_User";

        //        SqlCommand comm = new SqlCommand(insql, conn);
        //        SqlDataReader sdr = comm.ExecuteReader();
        //        List<UserInfo> mlist = new List<UserInfo>();
        //        UserInfo uinfo = null;
        //        while (sdr.Read())
        //        {
        //            uinfo = new UserInfo();
        //            uinfo.UserLogName = sdr.GetString(0);
        //            uinfo.UserName = sdr.GetString(1);
        //            uinfo.QuanXian = sdr.GetString(2);
        //            mlist.Add(uinfo);
        //        }
        //        sdr.Close();
        //        return mlist;
        //    }
        //}

        //public IList<UserInfo> GetUserName(string query,int pagesize, int startindex)
        //{
        //    using (SqlConnection conn = new SqlConnection("server=localhost;database=TestDb;uid=sa;pwd=11"))
        //    {
        //        conn.Open();
        //        Hashtable ht = new Hashtable();
        //        int prev = startindex * pagesize + 1;
        //        int next = pagesize * (startindex - 1);
        //        ht["next"] = next;
        //        ht["prev"] = prev;
        //        ht["query"] = query;
        //        string insql = GetSqlStatements.GetSelect("select_usercount", ht); //"select UserLogName,UserName,isnull(QuanXian,'') FROM Tbt_User";

        //        SqlCommand comm = new SqlCommand(insql, conn);
        //        SqlDataReader sdr = comm.ExecuteReader();
        //        List<UserInfo> mlist = new List<UserInfo>();
        //        UserInfo uinfo = null;
        //        while (sdr.Read())
        //        {
        //            uinfo = new UserInfo();
        //            uinfo.UserLogName = sdr.GetString(0);
        //            uinfo.UserName = sdr.GetString(1);
        //            uinfo.QuanXian = sdr.GetString(2);
        //            mlist.Add(uinfo);
        //        }
        //        sdr.Close();
        //        return mlist;
        //    }
        //}

        //public List<UserInfo> GetUserName(string query)
        //{
        //    using (SqlConnection conn = new SqlConnection("server=localhost;database=TestDb;uid=sa;pwd=11"))
        //    {
        //        conn.Open();
        //        Hashtable ht = new Hashtable();
        //        ht["query"] = query;
        //        string insql = GetSqlStatements.GetSelect("select_user", ht); 

        //        SqlCommand comm = new SqlCommand(insql, conn);
        //        SqlDataReader sdr = comm.ExecuteReader();
        //        List<UserInfo> mlist = new List<UserInfo>();
        //        UserInfo uinfo = null;
        //        while (sdr.Read())
        //        {
        //            uinfo = new UserInfo();
        //            uinfo.UserLogName = sdr.GetString(0);
        //            uinfo.UserName = sdr.GetString(1);
        //            uinfo.QuanXian = sdr.GetString(2);
        //            mlist.Add(uinfo);
        //        }
        //        sdr.Close();
        //        return mlist;
        //    }
        //}

        //public int SaveUser(UserInfo puinfo)
        //{
        //    using (SqlConnection conn = new SqlConnection("server=localhost;database=TestDb;uid=sa;pwd=11"))
        //    {
        //        conn.Open();
        //        Hashtable ht = new Hashtable();
        //        ht["uinfo"] = puinfo;
        //        string insql = GetSqlStatements.ExeInsert("insert_user", ht);

        //        SqlCommand comm = new SqlCommand(insql, conn);
        //        int rows = comm.ExecuteNonQuery();
        //        return rows;
        //    }
        //}
    }
}
